package com.zeng.service.impl;

import com.zeng.dao.KindsDao;
import com.zeng.entity.Kinds;
import com.zeng.service.KindsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Kinds)表服务实现类
 *
 * @author zengfanchao
 * @since 2021-03-17 19:17:04
 */
@Service("kindsService")
public class KindsServiceImpl implements KindsService {
    @Resource
    private KindsDao kindsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param kid 主键
     * @return 实例对象
     */
    @Override
    public Kinds queryById(Integer kid) {
        return this.kindsDao.queryById(kid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Kinds> queryAllByLimit(int offset, int limit) {
        return this.kindsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param kinds 实例对象
     * @return 实例对象
     */
    @Override
    public Kinds insert(Kinds kinds) {
        this.kindsDao.insert(kinds);
        return kinds;
    }

    /**
     * 修改数据
     *
     * @param kinds 实例对象
     * @return 实例对象
     */
    @Override
    public Kinds update(Kinds kinds) {
        this.kindsDao.update(kinds);
        return this.queryById(kinds.getKid());
    }

    /**
     * 通过主键删除数据
     *
     * @param kid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer kid) {
        return this.kindsDao.deleteById(kid) > 0;
    }

    @Override
    public List<Kinds> selectAll() {
        return this.kindsDao.selectAll();
    }

    @Override
    public List<Kinds> selectKey(String key) {
        return this.kindsDao.selectKey(key);
    }

    @Override
    public List<Kinds> selectByEntity(Kinds kinds) {
        return this.kindsDao.queryAll(kinds);
    }

    @Override
    public List<Kinds> queryAll(Kinds kinds) {
        return this.kindsDao.queryAll(kinds);
    }
}